﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Imgalib.Utility
{
    public class StringFormatter
    {
        public static String CreateCleanUrl(String name, String extension)
        {
            String fileName = Regex.Replace(name, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            fileName = Regex.Replace(fileName, @"[\s]+", "_", RegexOptions.Compiled).ToLowerInvariant() + "." + extension; 
            return fileName;
        }

        public static String CreateCleanUrl(String name)
        {
            String fileName = Regex.Replace(name, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            fileName = Regex.Replace(fileName, @"[\s]+", "_", RegexOptions.Compiled).ToLowerInvariant() + ".aspx";
            return fileName;
        }
    }
}
